package com.light.sword;

import com.alibaba.fastjson.JSON;

import java.math.BigDecimal;
import java.util.HashMap;

public class HelloWorld {


    public static void main(String[] args) {
        testHashMap();
//        testForLoop();
//        testDoubleToInt();
    }

    private static void testDoubleToInt() {
        String a = "1.0";
        Double d = Double.valueOf(a);
        Integer i = d.intValue();
        System.out.println(i.toString());


        String a1 = "2.0";
        String a2 = "1.8";
        BigDecimal quotaValue = BigDecimal.ZERO;
        quotaValue = quotaValue.add(BigDecimal.valueOf(Double.valueOf(a1)));
        quotaValue = quotaValue.add(BigDecimal.valueOf(Double.valueOf(a2)));
        quotaValue = quotaValue.setScale(0, BigDecimal.ROUND_HALF_UP);
        System.out.println(quotaValue);
    }

    private static void testForLoop() {
        for (int i = 0; i < 10; i++) {
            System.out.println(i);
        }

        for (int i = 0; i < 10; ++i) {
            System.out.println(i);
        }
    }

    private static void testHashMap() {
        HashMap hashMap = new HashMap(7);
        System.out.println(JSON.toJSONString(hashMap));

        hashMap.put("1","A");
        hashMap.put("1","A");
        System.out.println(JSON.toJSONString(hashMap));
        hashMap.put("1","A");
        hashMap.put("1","B");
        System.out.println(JSON.toJSONString(hashMap));

        hashMap.put("1","A");
        hashMap.put("2","B");
        System.out.println(JSON.toJSONString(hashMap));
    }


}
